import requests
import json
url="https://fanyi.baidu.com/langdetect"

#加入反爬代理机制
headers={
    "user-agent":"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36 Edg/111.0.1661.54"
}
data={
     "query":"dog"
}
response=requests.post(url,headers=headers,data=data)
dic_obj = response.json()
print(dic_obj)
#进行持久化存储
fp =open('./dog.json','w',encoding='utf-8')
json.dump(dic_obj,fp=fp,ensure_ascii=False)
fp.close()
print("over")
